<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: 李家伟
  Date: 2019/9/27
  Time: 18:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>回答详情</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/dist/css/bootstrap.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/dist/css/bootstrap-theme.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/question_details.css">
    <script src="${pageContext.request.contextPath}/js/jquery-3.4.1.js"></script>
    <script src="${pageContext.request.contextPath}/dist/js/bootstrap.js"></script>
    <script src="${pageContext.request.contextPath}/js/question_details.js"></script>
</head>
<body>
<c:choose>
    <c:when test="${memberall.userId != 0}">
        <c:if test="${memberall.userStatus == 0}">
            <img src="http://localhost:8080/mydev/images/vip.png" style="position:absolute;top:23px;right: 345px;z-index: 999;">
        </c:if>
        <c:if test="${memberall.userStatus == 1}">
            <a href="http://localhost:8080/mydev/VIP" style="position:absolute;top:13px;right: 400px;z-index: 999;">开通vip</a>
        </c:if>
    </c:when>
</c:choose>
<div class="header-container" style="width: 100%; min-width: 1500px;  ">

    <div class="row first-div" style="z-index: 999; width: 100%">
        <div class=" left-nav-ul" >
        </div>


        <ul class="mid-nav-ul" >
            <li class="nav-ul-li" >
                <a   style="text-decoration: none" href="http://localhost:8080/mydev/start/index">
                    <div>
                        <img src="http://localhost:8080/mydev/images/logo.png">
                        逍遥游
                    </div>
                </a>

            </li>
            <li class="nav-ul-li" style="background-color: #ff9d00">
                <a style="text-decoration: none;color: #ffffff" href="http://localhost:8080/mydev/start/index">首页</a>
            </li>
            <li class="nav-ul-li">
                <a  style="text-decoration: none" href="http://localhost:8080/mydev/QuestionTable/club_questions">问答</a>
            </li>

            <li class="nav-ul-li">
                <a   style="text-decoration: none" href="http://localhost:8080/mydev/clublist/list">鲲鹏俱乐部</a>
            </li>

            <li class="nav-ul-li new">
                <div class="geren">
                    <a  style="text-decoration: none; color:black" href="">更多</a>
                    <div class="t1"></div>
                </div>
                <div class="hidden1">
                    <ul class="geren-ul">
                        <li>
                            <a  style="text-decoration: none" href="http://localhost:8080/mydev/write/travel">写游记</a>
                        </li>
                        <li>
                            <a  style="text-decoration: none"  href="http://localhost:8080/mydev/myhome/mytravel/${memberall.userId}">我的游记</a>
                        </li>
                    </ul>
                </div>
            </li>

            <li class="nav-ul-li" >
                <c:choose>
                    <c:when test="${memberall.userId != 0}">
                        <c:if test="${memberall.userStatus ==0}">
                             <span  style="color: gold">
                                 欢迎!${memberall.userName}
                             </span>
                        </c:if>
                        <c:if test="${memberall.userStatus ==1}">
                             <span  style="color: black">
                                 欢迎!${memberall.userName}
                             </span>
                        </c:if>


                    </c:when>
                    <c:otherwise>
                        <a  style="text-decoration: none" href="http://localhost:8080/mydev/regist/normalRegist">注册</a>
                    </c:otherwise>
                </c:choose>

            </li>
            <li class="nav-ul-li">
                <c:choose>
                    <c:when test="${memberall.userId != 0}">

                    </c:when>
                    <c:otherwise>
                        <a  style="text-decoration: none" href="http://localhost:8080/mydev/login/login">登陆</a>
                    </c:otherwise>
                </c:choose>


            </li>
        </ul>




        <c:choose>
            <c:when test="${memberall.userId != 0}">

                <div class="right-nav-ul" >
                    <div class="topmaguser" style="  position:relative;left: 0px;top:2px">


                        <a href="http://localhost:8080/mydev/myhome/mytravel/${memberall.userId}" >
                            <img src="http://localhost:8080/mydev/${memberall.userPicture}">
                        </a>

                    </div>
                    <ul class="right-mid" >
                        <li class="nav-ul-li new" >

                            <div class="geren">

                                <a style="text-decoration: none; color:black" href="">个人中心</a>

                                <div class="t2"></div>
                            </div>

                            <div class="hidden1">
                                <ul class="gere-ul">

                                    <li style="height: 45px;">
                                        <a  style="text-decoration: none" href="http://localhost:8080/mydev/myfoot/collect/${memberall.userId}"><img src="http://localhost:8080/mydev/images/savea.png">我的收藏</a>
                                    </li>
                                    <li style="height: 45px;">
                                        <a  style="text-decoration: none" href="http://localhost:8080/mydev/myfoot/mapview/${memberall.userId}"><img src="http://localhost:8080/mydev/images/foot.png">我的足迹</a>
                                    </li>
                                    <li style="height: 45px;">
                                        <a  style="text-decoration: none" href="http://localhost:8080/mydev/myfoot/answer/${memberall.userId}"><img src="http://localhost:8080/mydev/images/question.png">我的问答</a>
                                    </li>
                                    <li style="height: 45px;">
                                        <a  style="text-decoration: none" href="http://localhost:8080/mydev/reply/toaccount/${memberall.userId}"><img src="http://localhost:8080/mydev/images/question.png">回复消息</a>
                                    </li>

                                    <li style="height: 45px;">
                                        <a  style="text-decoration: none" href="http://localhost:8080/mydev/exit"><img src="http://localhost:8080/mydev/images/banka.png">退出登录</a>
                                    </li>
                                </ul>
                            </div>
                        </li>
                    </ul>
                </div>
            </c:when>
            <c:otherwise>



            </c:otherwise>
        </c:choose>

    </div>
</div>

<!--主体部分-->
<div class="main1">
    <div class="col-md-2 left-main1"></div>
    <div class="col-md-6 mid-main1">
        <a href="" style="color: #ff9d00">逍遥问答</a>
        <span> > </span>
        <span>${questionVO.question.queTitle}</span>  <br>

        <div class="search-area">
            <input type="text" class="text2" placeholder="提问之前请看问题有没有被提问过哦">
            <input type="submit" class="submit2 " value=" "> <br> <br>
            <span style="font-size: 18px;font-weight: bolder;line-height: 30px">${questionVO.question.queTitle}</span><br>
            <span>${questionVO.question.queText}</span>
        </div>

        <div class="question-title">
            <img src="${questionVO.question.queOther1}" style="width: 500px;height: 300px;">
            <br>
            <div class="q-tags fl">
                <a class="a-tag" href="" target="_blank">${questionVO.question.queClasstitle}</a>
                <%--<a class="a-tag" href="" target="_blank">欧洲</a>--%>
                <%--<a class="a-tag" href="" target="_blank">民宿</a>--%>
                <%--<a class="a-tag" href="" target="_blank">住宿</a>--%>
            </div> <br>
            <div class="question-writer">
                <img src="">
                <span>${questionVO.member.userName}</span>
                <span>发布于<fmt:formatDate value="${questionVO.question.queTime}" pattern="yy-MM-dd hh:ss"/></span>
            </div>
            <hr>

            <%--<span>368</span>  <span>人关注</span>--%>
            <a href="#my-answer1">
                <input class="answerquestion" type="button" value="回答">
                <%--<input class="looklook" type="button" value="关注">--%>
            </a>
        </div>


        <div class="allanswer">
            <span>${questionVO.answerVOList.size()}</span> <span>个回答</span>

            <c:forEach var="answermain" items="${questionVO.answerVOListMap}">
                <div class="answer1">
                    <hr>
                    <img src="${pageContext.request.contextPath}/${answermain.key.member.userPicture}" class="img-circle"style="width: 48px;height: 48px">
                    <span style="color: #ff9d00;font-size: 17px">${answermain.key.member.userName}</span>
                    <p>${answermain.key.answer.ansText}</p>

                    </br>
                    <div class="reply-area1">
                      <%--  <a href=""> 点赞 </a>--%>
                        <a href="">收藏</a>
                        <span style=" font-size: 12px;line-height: 14px;color: #999;">发布于</span>
                        <span style=" font-size: 12px;line-height: 14px;color: #999;"><fmt:formatDate value="${answermain.key.answer.ansTime}" pattern="yy-MM-dd hh:mm"/></span>

                        <details style="white-space:nowrap;">
                            <summary style="color: #999;font-size: 12px;">添加评论</summary>

                            <span>全部评论</span>
                            <ul class="comment-list _j_comment_list_ul">

                                <c:forEach var="commentmain" items="${answermain.value}">
                                    <li class="comment-item clearfix" data-cid="19405963" data-username="" style="list-style: none">
                                        <div class="comment-user">
                                            <a href="/u/85170770.html" target="_blank"><img src="${pageContext.request.contextPath}/${commentmain.member.userPicture}" class="img-circle"style="width: 48px;height: 48px"></a>
                                        </div>
                                        <dl>
                                            <dt>
                                                <a href="/u/85170770.html" target="_blank" class="c-name">${commentmain.member.userName}</a>
                                                    ${commentmain.ancomm.ancoText}
                                            </dt>
                                            <dd>
                                                <div class="c-info">
                                                    <span class="c-time fl"><fmt:formatDate value="${commentmain.ancomm.ancoTime}" pattern="yy-MM-dd hh:mm"/></span>
                                                </div>
                                            </dd>
                                        </dl>
                                    </li>
                                </c:forEach>

                            </ul>

                            <div class="comment-add clearfix _j_word">
                                <textarea class="_j_content _j_word_check" id="pinglun${answermain.key.answer.ansId}"></textarea>
                                <span class="word-count"><span class="_j_word_num">0</span>/<span class="_j_max_num">600</span> 字</span>
                                <input class="btn-comment _j_publish_comment" type="button" value="回复" onclick="ancomm(${answermain.key.answer.ansId})">
                            </div>

                        </details>

                    </div>

                </div>
            </c:forEach>

            <script>
                function ancomm(answersid) {

                    var ancommText=$("#pinglun"+answersid).val()

                    console.log(ancommText)
                    var questionid =${questionVO.question.queId};
                    var answerid = answersid;
                    if(ancommText.length>10){
                        $.ajax({
                            type:"POST",
                            data:{
                                ancommText:ancommText,
                                questionid:questionid,
                                answerid:answerid

                            },
                            datetype:"json",
                            url:"${pageContext.request.contextPath}/write/answercomm",

                            success:function (result) {
                                console.log(ancommText); /*console.log(dibiaoid);*/ console.log(answerid);
                                window.location.href="${pageContext.request.contextPath}/question/${questionVO.question.queId}" ;
                            },
                            error:function (result) {
                                console.log(ancommText); console.log(dibiaoid); console.log(answerid);
                                window.location.href="${pageContext.request.contextPath}/question/${questionVO.question.queId}"

                            }



                        })

                    }else{
                        alert("10个字")
                    }




                }
            </script>

        </div>

        <hr>
        <div class="my-answer1" id="my-answer1">

            <form action="" method="post" >
                <label><strong>${memberall.userName}</strong></label><br>
                <textarea style="width: 850px;height: 350px" id="qxxndhf">请写下你的回复</textarea><br>

            </form>

            <button class="commit-reply" value="提交回答" onclick="answer()">提交回答</button>
            <script>
                function answer() {
                    var title = $("#qxxndhf").val();
                    var memberid = ${memberall.userId};
                    var ansid = ${questionVO.question.queId}

                    $.ajax({
                        type:"POST",
                        data:"title="+title+"&memberid="+memberid+"&ansid="+ansid,
                        datatype:"json",
                        url:"${pageContext.request.contextPath}/write/quesanswer",
                        success:function (result){
                            window.location.href="${pageContext.request.contextPath}/question/${questionVO.question.queId}"
                        },
                        error:function (result) {
                            window.location.href="${pageContext.request.contextPath}/question/${questionVO.question.queId}"

                        }
                    })


                }
            </script>

        </div>
    </div>

    <div class="col-md-4 right-main1">
        <div class="jump-question">
            <a  href="${pageContext.request.contextPath}/write/question">我要提问</a>
        </div>
    </div>
</div>

</body>
</html>
